<?php
namespace App\Repository\Java;

use App\Repository\Contracts\OrderJavaInterface;

/**
 * @Author:: HuangYin
 * @DateTime: 2017-02-06 13:42
 *
 * @Description:
 */
class OrderRepository extends Repository implements OrderJavaInterface
{
    protected function setPrefix()
    {
        $this->prefix = '';
    }

    public function syncCreated($storeId, array $data)
    {
        $form = [];
        foreach ($data['detail'] as $key => $val) {
            $form['billNO'] = $data['number'];
            $form['outInStockApplyEntryList'][$key]['seq'] = $val['id'];
            $form['outInStockApplyEntryList'][$key]['goodsId'] = $val['goods_id'];
            $form['outInStockApplyEntryList'][$key]['inStockPlaceId'] = $storeId;
            $form['outInStockApplyEntryList'][$key]['qty'] = $val['counts'];
        }
        $result = $this->post('outinstockapply/addSaveOutInStockApply', $form);

        return $result['resultType'] === 'success';
    }

    public function syncUpdated($number)
    {
        $result = $this->get(env('JAVA_RESOURCE').'outinstock/approveOutInStockByBillId.jhtml?srcBillNO='.$number);

        return $result['resultType'] === 'success';
    }
}